'use strict';

const BaseService = require('../library/base-service');
const AnchorMapper = require("../database/mapper/anchor")
const UserMapper = require("../database/mapper/user")
const {checkCookieIsExpire,checkCookieField} = require("../utils/fun");
const RedPacketBo = require("../bo/red-packet-bo");
const {sleep} = require("ee-bin/tools/serve");
const Scanf = require("../task/scanf");
const TestScanf = require("../test/scanf");


/**
 * 示例服务（service层为单例）
 * @class
 */
class AnchorService extends BaseService {
    taskMap = {}

    async scanf(id, channel, sender){
        this.taskMap[id]  = new Scanf(id, channel, sender)
        this.taskMap[id].run()
    }
    testScanf(id, channel, sender){
        let scanTask = new TestScanf(id)
        scanTask.setSender(sender).setChannel(channel)
        this.taskMap[id]  = scanTask
        this.taskMap[id].run()
    }
     has(id){
        return id in this.taskMap
     }

    async stop(id){
        this.taskMap[id].stop(id)
        delete this.taskMap[id] //释放资源
    }




}
module.exports = AnchorService;